package com.nbooo.ui
{
	
	import com.somewater.control.IClear;
	import com.somewater.display.Window;
	import com.somewater.storage.Lib;
	import com.somewater.text.TruncatedTextField;
	
	import flash.display.Sprite;
	import flash.text.TextField;
	
	public class BaseMenu extends Sprite implements IClear
	{
		
		private var header:Sprite;
		private var ground:Sprite;
		private var footer:Sprite;
		private var titleField:TruncatedTextField;
		
		protected const WIDTH:int = 800;
		protected const HEIGHT:int = 600;
		
		public function BaseMenu(_title:String, _closeFunc:Function, _buttons:Array )
		{
			super();
			init();
		}
		
		public function clear():void
		{
			while ( this.numChildren > 0)
			{
				removeChildAt(0);
			}
		}
		public function close():void
		{
		}
		public function resize():void
		{
			if(titleField)
			{
				titleField.maxWidth = width - 100;
				titleField.x = (width - titleField.width) * 0.5 + 10;
			
			}
			header.width = this.width;
			footer.width = this.width;
			footer.y = height - footer.height;
			ground.width = this.width;
			ground.height = this.height;
		}
		
		protected function setSize(_width:int, _height:int):void
		{
			/*this.width = _width;
			this.height = _heigth;
			resize();*/
			
			header.width =_width;
			footer.width = _width;
			footer.y = _height - footer.height;
			ground.width = _width;
			ground.height = _height;
			
		}
		
		protected function init():void
		{
		
			
			header = Lib.getMc("WindowHeader");
			footer = Lib.getMc("WindowFooter");
			ground = Lib.getMc("WindowGround");
			
			addChild(ground);
			addChild(header);			
			addChild(footer);
			
			setSize(WIDTH, HEIGHT);
			
		}
	}
}